package com.yang.doctorrecruitment.action;

import com.opensymphony.xwork2.ActionSupport;
import com.yang.doctorrecruitment.dao.UserloginDAO;
import com.yang.doctorrecruitment.dto.UserLogin;

public class RegisterAction extends ActionSupport {
    private String UserName;
    private String PassWord;
    private String Select;
    public String execute() throws Exception{
  	 boolean res= UserloginDAO.findUserNameAndPassWord(UserName, PassWord);
  	 if(res){
  		 return ERROR;
  	 }else {
		 System.out.println("Select" + Select);
		 UserLogin userinfo = new UserLogin(UserName, PassWord, Select);
		 boolean result = UserloginDAO.registerByUserInfo(userinfo);
		 if (result) {
			 UserLogin ul = new UserLogin();
			 ul.setUserName(UserName);
			 boolean findID = UserloginDAO.findUserLogin(ul);
			 //拿到UserID，根据userkind选择将信息插入哪里
			 //如果是普通用户，需要向userresume表中插入一条userid，后续用户修改简历时分步修改需要根据UserID修改
			 if (findID){
			 	boolean insert=UserloginDAO.InsertUserIDtoUser(ul.getUserID());
			 	return SUCCESS;
			 }else{
			 	return ERROR;
			 }

		 } else {
			 return ERROR;
		 }
	 }
  	 
    }
	 public String getUserName() {
		return UserName;
	}
	public void setUserName(String userName) {
		UserName = userName;
	}
	public String getPassWord() {
		return PassWord;
	}
	public String getSelect() {
		return Select;
	}
	public void setSelect(String select) {
		Select = select;
	}
	public void setPassWord(String passWord) {
		PassWord = passWord;
	}
  
}